<template>
<div>
<centerHeader :title="header"></centerHeader>
  <div class="publicaccess">
      <p>
          <span><h1 style="display:inline-block">公众号设置</h1>&nbsp;(微信后台&nbsp;>&nbsp;公众号设置&nbsp;>&nbsp;功能设置)</span>
      </p>
      <p>
          <span class="publicsetup_item_left">业务域名:</span>
          <span class="itemccc">{{"d"+user_id+'.131452.com'}}</span>
      </p>
      <p>
          <span class="publicsetup_item_left">JS接口安全域名:</span>
          <span class="itemccc">{{"d"+user_id+'.131452.com'}}</span>
      </p>
      <p>
          <span class="publicsetup_item_left">网页授权域名:</span>
          <span class="itemccc">{{"d"+user_id+'.131452.com'}}</span>
      </p>
      <p>
          <span><h1 style="display:inline-block">公众号回复</h1>(微信后台&nbsp;>&nbsp;基本配置)</span>
      </p>
      <p>
          <span class="publicsetup_item_left">URL(服务器地址):</span>
          <span class="itemccc">{{WxInfo.service}}</span>
          <!-- <span>{{WxInfo.service+user_id}}</span> -->
      </p>
      <p>
          <span class="publicsetup_item_left">Token(令牌):</span>
          <span class="itemccc">{{WxInfo.token}}</span>
      </p>
      <p>
          <span class="publicsetup_item_left">EncodingAESKey(消息加解密密钥):</span>
          <!-- <span>{{WxInfo.encode_key}}</span> -->
          <span class="itemccc">随机生成</span>
      </p>
      <p>
          <span class="publicsetup_item_left">消息加解密方式:</span>
          <span class="itemccc">明文模式</span>
      </p>
      <p class="scmenu">
       <span @click="setmenu">生成菜单</span> 
      </p>
  </div>
  </div>
</template>
<script>
import centerHeader from "../../../components/center-header";
export default {
  data() {
    return {
      WxInfo: "",
      user_id: "",
      https: "https://",
      http: "http://d",
      cp: "/cp/v1/Custom/index",
      header: [{ title: "公众号接入", path: "/home/setup/publicaccess" }]
    };
  },
  components: {
    centerHeader
  },
  methods: {
    getWxInfo(user_id) {
      let that = this;
      that.axios
        .post("/cp/v1/User/getWxInfo", {
          user_id: user_id
        })
        .then(res => {
          if (res.data.code == 200) {
            that.WxInfo = res.data.data;
          }
          console.log(that.WxInfo);
        });
    },
    setmenu() {
      let that = this;
      that.axios
        .post("/cp/v1/custom/createmenu", {
          d_id: that.user_id
        })
        .then(res => {
          console.log(res);
          if (res.data.code == 200) {
            that.$message.success("创建成功!");
          } else {
            that.$message.error("创建失败，网络异常!");
          }
        });
    }
  },
  created() {
    let that = this;
    that.user_id = JSON.parse(localStorage.userInfo).user_id;
    that.getWxInfo(that.user_id);
  }
};
</script>
<style scoped>
.publicaccess {
  height: 94%;
  position: relative;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding-top: 1%;
  padding-left: 10%;
}
.publicaccess h1{
  font-size: 18px;
}
.itemccc{
  margin-left: 28px;
}
.publicaccess > p {
  position: relative;
  margin-bottom: 40px;
}
.publicsetup_item_left {
  text-align: right;
  display: inline-block;
  width: 22%;
  padding-left: 6%;
}
.publicaccess > .scmenu > span {
  padding: 10px 30px;
  background: #36a4ff;
  color: #ffffff;
  position: relative;
  left: 35%;
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
}
</style>
